<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
      <h3>计算属性:</h3>
      <p>{{count}}</p>
      <p>{{count}}</p>
      <p>{{count}}</p>
      <p>{{count}}</p>
      <p>{{count}}</p>
      <hr>
      <h3>方法:</h3>
      <p>{{count1()}}</p>
      <p>{{count1()}}</p>
      <p>{{count1()}}</p>
      <p>{{count1()}}</p>
      <p>{{count1()}}</p>
    </div>
    <script src="js/vue.js"></script>
    <script>
        var vm = new Vue({
            el: '#app',
            data: {
              list:[2,3,4]
            },
            methods: {
              count1(){
                console.log('方法被调用了一次')
                return this.list.length 
              }
            },
            computed:{
              count(){
                console.log('计算属性被调用了一次')
                return this.list.length 
              }
            }
        });
    </script>
</body>

</html>